package 算法.力扣;

/**
 * @author: 谢君臣
 * @create: 2020-09-08 22:54
 * @founction: XXXX
 */
public class Reverse {
    public static void main(String[] args) {
        System.out.println(Integer.MAX_VALUE);
        System.out.println(reverse(-123));
    }

    public static int reverse(int x) {
        boolean flag = x > 0 ? true : false;
        long y= 0;
        x = Math.abs(x);
        while (x > 0) {
            y = y * 10 + x % 10;
            x /= 10;

        }
        if (flag) return (int)y==y? (int)y:0;
        else return (int)y==y? -(int)y:0;
    }
}
